package com.buaa.airticketbookingsystem.Controller;

import com.buaa.airticketbookingsystem.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
@CrossOrigin
@RestController
public class LogoutController {
    @Autowired
    private UserService userService;

    @PostMapping("/logout")
    public Map<String, Object> logout(@RequestBody Map<String, String> remap){
        String email = remap.get("email");
        Map<String, Object> resMap = new HashMap<>();
        try{
            userService.logout(email);
            resMap.put("res", true);
        } catch(Exception e){
            e.printStackTrace();
            resMap.put("res", false);
            resMap.put("message", "抛出异常");
            return resMap;
        }
        return resMap;
    }
}
